package com.shijie.service;

import com.shijie.mapper.AuthorsMapper;
import com.shijie.domain.entity.Authors;

import javax.annotation.Resource;

import org.joda.time.DateTime;
import org.springframework.stereotype.Service;

import com.shijie.component.ErpUserService;
import com.shijie.core.AbstractService;

/*
 *  @author: smart boy
 *  @date: 2018-08-06
 */
@Service
public class AuthorsService extends AbstractService<Authors> {

	@Resource
	private AuthorsMapper authorsMapper;
    @Resource
    private ErpUserService erpUserService;
    
	public void save(Authors authors){
		if(authors.getId() == null){
			authors.setCreateBy(erpUserService.getUserName());
			authors.setCreateTime(DateTime.now().toDate());
			authorsMapper.insert(authors);
		}else {
			authors.setUpdateBy(erpUserService.getUserName());
			authors.setUpdateTime(DateTime.now().toDate());
			authorsMapper.updateByPrimaryKey(authors);
		}
	}
}
